import { RedisClientType, RedisModules, RedisScripts } from 'redis';

export interface RedisConfigType {
    socket: {
        host: string;
        port: number;
    };
}

export declare type RedisClientTypes = RedisClientType<RedisModules, RedisScripts>;

export declare type ClientCreateCallback = (conn: RedisClientTypes, err: any | null) => void;

export declare type ClientCreate = (
    config: RedisConfigType,
    callback: ClientCreateCallback,
) => void;

export declare type RedisConnect = (options: RedisConfigType) => Promise<RedisClientTypes>;

export interface RedisToolType {
    setString(key: string, value: any, expire: number): Promise<string | null>;
    getString(key: string): Promise<string | null>;
    delString(key: string): Promise<number | null>;
    getDbSize(): Promise<number | null>;
    connToRedis(): Promise<null>;
}

export interface UserRedisDataType {
    email: string;
    password: string;
    activationCode: string;
}

export interface UserRedisType {
    setActivationInfo(data: UserRedisDataType): Promise<boolean>;
    getActivationInfo(email: string): Promise<UserRedisDataType | null>;
    delActivationInfo(email: string): Promise<boolean>;
}
